package rmi.operacao;

import java.rmi.RemoteException;

import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;

import rmi.client.CpuData;



public class OperacaoMultiplicacao implements IOperacao {

	private double operando1 = 0d;
	private double operando2 = 0d;
	private double result = 0d;
	private Double cpu;
	
	@Override
	public double executar(double operando1, double operando2)
			throws RemoteException {
		this.operando1 = operando1;
		this.operando2 = operando2;
		
		this.result = this.operando1 * this.operando2;
		System.out.println(this.getRepresentacao());
		return this.result;
	}

	@Override
	public String getOperacaoNome() throws RemoteException {
		return "Multiplicacao";
	}

	@Override
	public String getOperacaoSinal() throws RemoteException {
		return "*";
	}

	@Override
	public String getRepresentacao() throws RemoteException {
		return ""+this.getOperacaoNome()+" de "+String.valueOf(this.operando1)+" "+this.getOperacaoSinal()+" "+String.valueOf(this.operando2)+" = "+String.valueOf(this.result);
	}

	public double getCpuUsage() throws RemoteException {
		try {
			CpuData cpuDt = new CpuData(new Sigar());
			this.cpu = cpuDt.getIdle();
			System.out.println("Cpu: " + this.cpu);
		} catch (SigarException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	
		return this.cpu;
	}

	public String infoCpu() throws RemoteException {
		try {
			CpuData cpuDt = new CpuData(new Sigar());
			return cpuDt.cpuInfo();
		} catch (SigarException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		return "error!";
	}

}
